<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link href="./css/api.css" rel="stylesheet"/>
  <link href="./css/element.css" rel="stylesheet"/>
  <link href="./css/base.css" rel="stylesheet"/>
  <title>查看</title>
</head>
<body>
  <div id="vm" v-cloak>
    <header class="x-header">
      <i class="el-icon-arrow-left x-closewin-icon" @click="closethiswin"></i>
      <div class="x-header-t">查看</div>
    </header>
    <div class="x-onjob-top">
      <div class="x-onjob-l" v-if="infoavatar!=''"><img :src="infoavatar" alt=""></div>
      <div class="x-onjob-l" v-else><img src="./images/myhead.png" alt=""></div>

      <div class="x-onjob-r">
        <div class="x-on-name">{{infoname}}</div>
        <div class="x-on-desc">面试时间：{{timestampToTime(infofacetime)}}</div>
        <div class="x-on-desc">入职时间：{{timestampToTime(infoentertime)}}</div>
        <div class="x-on-desc">当前店面：{{infostare}}</div>
        <div class="x-on-desc">当前职位：{{infowork}}</div>
      </div>
    </div>
    <!--  -->
    <div class="x-onjob-btnbox">
      <div class="x-mana-btn" @click="">查看入职资料</div>
      <div class="x-mana-btn" @click="">查看培训档案</div>
      <div class="x-mana-btn" @click="">查看结果呈现</div>
      <div class="x-mana-btn" @click="">管理</div>
      <div class="x-mana-btn" @click="removenopass">离职</div>
    </div>
  </div>
  <script type="text/javascript" src="./script/vue.js"></script>
  <script type="text/javascript" src="./script/element.js"></script>
  <script type="text/javascript" src="./script/api.js"></script>
  <script type="text/javascript" src="./js/base.js"></script>
  <script>
    apiready = function () {
      var jobid = api.pageParam.id;
      console.log(jobid);
      //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          infoid:'',
          infoname:'',
          infoavatar:'',
          infofacetime:'',
          infoentertime:'',
          infostare:'',
          infowork:'',
        }
      },
      created:function() {
        var that=this;

      },
      mounted:function(){
        var that=this;
        that.infoid = jobid;
        that.getdata()
      },
      methods: {
        getdata:function(){
          var that=this;
          console.log(that.infoid);
          api.ajax({
            url:manastore+'info',
            methods:'get',
            data:{
              values:{
                sec:$api.getStorage('usertoken'),
                id:that.infoid
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.infoname = ret.data.username;
                that.infoavatar = ret.data.avatar;
                console.log(that.infoavatar);
                that.infofacetime = ret.data.audition_time;
                that.infoentertime = ret.data.entry_time;
                that.infostare = ret.data.store_title;
                that.infowork = ret.data.work_title;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        // 时间戳转日期
        timestampToTime:function(time) {
          var that=this;
          var date = new Date(time * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
          Y = date.getFullYear()
          M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
          console.log(M);
          D = that.change(date.getDate())
          console.log(D);
          h = that.change(date.getHours())
          m = that.change(date.getMinutes())
          s = that.change(date.getSeconds())
          console.log(h);
          console.log(m);
          console.log(s);
          // return Y + '.' + M + '.' + D + '.' + h +':' + m + ':' + s
          return Y + '.' + M + '.' + D 
        },
        change:function(t) {
          if (t < 10) {
              return "0" + t;
          } else {
              return t;
          }

        },
        removenopass:function(){
          var that=this;
          api.confirm({
              title: '确定离职吗',
              msg: '',
              buttons: ['确定', '取消']
          }, function(ret, err) {
              var index = ret.buttonIndex;
              if(index==1){
                that.editjob()
              }
          });

        },
        editjob:function(){
          var that=this;
          console.log(that.infoid);
          api.ajax({
            url:manastore+'leave',
            methods:'get',
            data:{
              values:{
                sec:$api.getStorage('usertoken'),
                id:that.infoid
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.sendEvent({
                    name: 'leavesuss',
                    extra: {}
                });
                api.alert({
                    title: '离职成功',
                    msg: '',
                }, function(ret, err) {
                    closethiswin()
                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
    }
  </script>
</body>
</html>
